import 'package:get/get.dart';
import 'package:star_author/provider/config.dart';
import 'package:star_author/utils/common_util/num_util.dart';
import 'package:provider/provider.dart';

class ConfigProviderUtil {
  static Map get setting {
    ConfigProvider configProvider =
        Provider.of<ConfigProvider>(Get.context!, listen: false);
    Map setting = configProvider.get("settings") ?? {};
    return setting;
  }

  ///黄金回流单待打款时间单位
  static int get gold_transfer_interval_hours {
    return setting['gold_transfer_interval_hours'] ?? 24;
  }

  ///回款倒计时为等待买家支付中拍款的时间，如deduct_guarantee_duration_hours小时内买家未支付中拍款
  static int get deduct_guarantee_duration_hours {
    return setting['deduct_guarantee_duration_hours'] ?? 24;
  }

  ///未达结拍人数的回流单，将在上架竞拍expired_evaluation_duration小时后自动结拍；
  static int get expired_evaluation_duration {
    return setting['expired_evaluation_duration'] ?? 48;
  }

  ///毁标赔偿比例和冻结出价保证金比例
  static double get deduct_guarantee_rate {
    return setting['deduct_guarantee_rate'] ?? 0.1;
  }

  static String get deduct_guarantee_rate_str {
    return NumUtil.multiply(deduct_guarantee_rate, 100).toInt().toString() +
        "%";
  }

  ///可出价B倍
  static int get available_bid_multiple {
    return setting['available_bid_multiple'] ?? 10;
  }

  ///保证金超过A时出价不限额度 /最高扣违约金A
  static int get max_deductible_amount {
    return setting['max_deductible_amount'] ?? 1000;
  }

  ///最高赔偿
  static int get max_compensation {
    return setting['max_compensation'] ?? 800;
  }

  ///支付保证金的最小金额
  static int get minimum_earnest_money_price {
    return setting['minimum_earnest_money_price'] ?? 100;
  }

  static bool get auditing_version {
    return setting['auditing_version'] ?? true;
  }

  static List get express_company_normal {
    return setting['express_company_normal'] ?? ['shunfeng', 'jd'];
  }

  static int get transfer_backflow_paid_days_limit {
    return setting['transfer_backflow_paid_days_limit'] ?? 7;
  }

  ///取消回流单限制天数
  static int get transfer_backflow_send_back_days_limit {
    return setting['transfer_backflow_send_back_days_limit'] ?? 7;
  }

  ///取回的中拍订单限制天数
  static int get transfer_backflow_taken_back_days_limit {
    return setting['transfer_backflow_taken_back_days_limit'] ?? 7;
  }

}
